/* eslint-disable @typescript-eslint/camelcase */
/**
 * Created by zhangsong on 2019-06-01.
 */
import moment from 'moment';
import { datetimeFormat, WorkCardDefault } from '@/constants/styleConfig';
import globalConfig from '@/constants/config';
import URI from '@/services/uri';
import _ from 'lodash';
import {
  requestPostByToken,
  requestGetByToken,
  requestPutByToken,
  requestDeleteByToken,
} from '@/utils/request';

const url = URI.application;

const setDataModify = list => {
  let arr = [];
  arr = Array.isArray(list)
    ? list.map((item, index) => {
      item.url = `${globalConfig.host}${globalConfig.baseAPI}${item.url}`;
      item.name = item.url.substring(item.url.lastIndexOf('/') + 1);
      item.uid = (index + 1) * -1;
      item.status = 'done';
      return item;
    })
    : []
  return arr;
}

const setDataList = list => {
  let annexesBase64 = [];
  if (Array.isArray(list)) {
    annexesBase64 = list.map(item => item.url || item.thumbUrl);
  }

  return annexesBase64
}

const setNewDataList = list => {
  let annexesBase64 = [];
  if (Array.isArray(list)) {
    annexesBase64 = list.map(item => item.thumbUrl);
  }

  return annexesBase64
}

export const registerEface = params =>
  requestPostByToken({
    url: url.person.registerEface,
    body: params,
  });

export const registerEfaceIcCon = data =>
  requestPutByToken({
    url: url.person.registerEfaceIcCon.replace('{id}', data.contractorId),
    body: { icCard: data.icCard },
  });

// 强制将记录更新为登记成功
export const forceRegisterSuccess = id =>
  requestPutByToken({
    url: url.person.forceUpdateSuccess,
    body: {
      contractorId: id,
    },
  });

export const listSubcontractor = () =>
  requestGetByToken({
    url: url.contractorUrl.listSubcontractor,
  });

/**
 * 审核通过
 * @param id
 */
export const approval = id =>
  requestGetByToken({
    url: url.contractorUrl.approval.replace('{id}', id),
  });

// 更新註銷日期
export const updateCallDate = async param => {
  const response = await requestPostByToken({
    url: url.contractorUrl.modifyacll,
    body: param,
  });
  return response;
}

// 获取group list
export const getGroupList = async () => {
  const response = await requestPostByToken({
    url: URI.common.getgrouplist,
    body: {},
  });
  return response;
}


// 新增group list
export const creatGroupList = async param => {
  const response = await requestPostByToken({
    url: URI.common.creatgrouplist,
    body: param,
  });
  return response;
}

// 獲取主合同變編號的list
export const getMainContractor = async () => {
  const response = await requestGetByToken({
    url: URI.application.contractorUrl.getMainContractor,
  });
  return response;
}

export const createMainContractor = async data => {
  const response = await requestPostByToken({
    url: URI.application.contractorUrl.createMainContractor,
    body: { contract_number: data },
  });
  return response;
}

// 审核不通过
export const disapproval = id =>
  requestGetByToken({
    url: url.contractorUrl.disapproval.replace('{id}', id),
  });

export const reviewok = id =>
  requestGetByToken({
    url: url.contractorUrl.reviewok.replace('{id}', id),
  });

export const getPDFById = id =>
  requestGetByToken({
    url: url.contractorUrl.pdf.replace('{id}', id),
  });

export const getDefaultData = id =>
  requestGetByToken({
    url: url.contractorUrl.defaultdata.replace('{id}', id),
  });

export const contractorDownXlsx = () =>
  requestGetByToken({
    url: url.contractorUrl.downxlsx,
  });

export const sendEmail = param =>
  requestPostByToken({
    url: url.contractorUrl.sendemail,
    body: param,
  });

export const listByParam = async query => {
  const {
    otherName,
    nameAlias,
    commercialCodeAlias,
    identityCard,
    placeOfBirth,
    telephoneSpare,
    checkedSpecified,
    emergencyContactedName,
    emergencyContactedRelationship,
    emergencyContactedAddress,
    emergencyContactedTelephone,
    pageSize,
    page,
    efaceStatus,
    ...other
  } = query;
  const users = JSON.parse(localStorage.getItem('user'));
  const result = await requestGetByToken({
    url: _.get(users, 'role_id') === '110' ? url.contractorUrl.permissions : url.contractorUrl.newlist,
    query: {
      ...other,
      page_size: pageSize,
      page_num: page,
      eface_status: efaceStatus,
      other_names: otherName,
      name_alias: nameAlias,
      commercial_code_alias: commercialCodeAlias,
      identity_card: identityCard,
      place_of_birth: placeOfBirth,
      telephone_spare: telephoneSpare,
      checked_specified: checkedSpecified,
      emergency_contacted_name: emergencyContactedName,
      emergency_contacted_relationship: emergencyContactedRelationship,
      emergency_contacted_address: emergencyContactedAddress,
      emergency_contacted_telephone: emergencyContactedTelephone,
    },
  });
  const rows = result.data.map(item => ({
    ...item,
    fileGroupId: item.file_group_id,
    createTime: item.create_time,
    updateTime: item.update_time,
    id: item.id,
    surname: item.surname,
    otherName: item.other_names,
    sex: item.sex,
    nameAlias: item.name_alias,
    commercialCodeAlias: item.commercial_code_alias,
    identityCard: item.identity_card,
    birthday: item.birthday,
    placeOfBirth: item.place_of_birth,
    nationality: item.nationality, // 国籍
    address: item.address,
    telephone: item.telephone,
    telephoneSpare: item.telephone_spare,
    // 紧急联系人
    emergencyContactedName: item.emergency_contacted_name,
    emergencyContactedRelationship: item.emergency_contacted_relationship,
    emergencyContactedAddress: item.emergency_contacted_address,
    emergencyContactedTelephone: item.emergency_contacted_telephone,

    // partB
    contractNumber: item.contract_number, // 主分包商编号
    contractPosition: item.contract_position,
    contractSubcontractor: item.contract_subcontractor,
    contractEmployer: item.contract_employer,
    contractFrom: item.contract_from, // 合同开始时间
    contractTo: item.contract_to, // 合同结束时间
    contractResident: item.has_resident,
    contractApplicantDrive: item.need_drivng, // 是否申请车辆通行证
    contractVehicle: item.contract_vehicle, // 车牌号

    // partC
    checkedApproved: item.checked_approved,
    checkedClassification: item.checked_classification,
    checkedSpecified: item.checked_specified,
    checkedExpiry: item.checked_expiry, // 申请过期时间
    checkedReasons: item.checked_reasons, // 申请拒绝原因
    cardFront: item.card_front,
    cardBack: item.card_back,
    // 头像
    // headPhoto: item.photograph_url,
    headPhoto: `${globalConfig.host}${globalConfig.baseAPI}${item.photograph_url}`,
    annexes: item.annex_list,
    efaceStatus: item.eface_status,
  }));
  return {
    data: rows,
    page: result.page,
    pageSize: result.page_size,
    total: result.total,
  };
};

export const getById = async id => {
  const data = await requestGetByToken({
    url: url.contractorUrl.getById.replace('{id}', id),
  });
  const result = {
    ...data,
    createTime: data.create_time,
    updateTime: data.update_time,
    drivingLicenseExpire: data.driving_license_expire,
    fileGroupId: data.file_group_id,
    cardGroupId: data.card_group_id,
    cardNo: data.card_no,
    id: data.id,
    surname: data.surname,
    otherName: data.other_names,
    sex: data.sex,
    nameAlias: data.name_alias,
    commercialCodeAlias: data.commercial_code_alias,
    identityCard: data.identity_card,
    birthday: data.birthday,
    placeOfBirth: data.place_of_birth,
    nationality: data.nationality, // 国籍
    address: data.address,
    telephone: data.telephone,
    telephoneSpare: data.telephone_spare,
    // 紧急联系人
    emergencyContactedName: data.emergency_contacted_name,
    emergencyContactedRelationship: data.emergency_contacted_relationship,
    emergencyContactedAddress: data.emergency_contacted_address,
    emergencyContactedTelephone: data.emergency_contacted_telephone,

    // partB
    contractNumber: data.contract_number, // 主分包商编号
    contractPosition: data.contract_position,
    contractSubcontractor: Number.parseInt(data.contract_subcontractor, 10),
    contractEmployer: data.contract_employer,
    contractFrom: data.contract_from, // 合同开始时间
    contractTo: data.contract_to, // 合同结束时间
    contractResident: data.has_resident,
    contractApplicantDrive: data.need_drivng, // 是否申请车辆通行证
    contractVehicle: data.contract_vehicle, // 车牌号
    contractNumberobj: data.contract_number ? { value: data.contract_number, label: data.contract_number } : undefined,

    // partC
    checkedApproved: data.checked_approved,
    checkedClassification: data.checked_classification,
    checkedSpecified: Array.isArray(data.zone_list) ? data.zone_list.map(i => i.id) : [],
    checkedExpiry: moment(data.checked_expiry).format(datetimeFormat.date), // 申请过期时间
    checkedReasons: data.checked_reasons, // 申请拒绝原因
    cardFront: data.card_front,
    cardBack: data.card_back,
    // 头像
    headPhoto: data.photograph_url
      ? [
        {
          id: -1,
          key: -1,
          uid: -1,
          status: 'done',
          url: `${globalConfig.host}${globalConfig.baseAPI}${data.photograph_url}`,
        },
      ]
      : [],
    annexes: setDataModify(data.annex_list),
    id_base64: setDataModify(data.id_paths),
    green_base64: setDataModify(data.green_paths),
    drive_base64: setDataModify(data.drive_paths),
    regist_base64: setDataModify(data.regist_paths),
    vacc_base64: setDataModify(data.vacc_paths),
    exemption_base64: setDataModify(data.exemption_paths),
    drive_certificate_base64: setDataModify(data.drive_certificate_paths),
    safety_certificate_base64: setDataModify(data.safety_certificate_paths),
    inspect_certificate_base64: setDataModify(data.inspect_certificate_paths),
    workerCardName1: WorkCardDefault.greenCard,
    workerCardName2: WorkCardDefault.registerCard,
    workerCardName3: WorkCardDefault.blueCard,
    efaceStatus: data.eface_status,
  };
  if (Array.isArray(data.card_list)) {
    data.card_list.forEach(i => {
      if (i.name === WorkCardDefault.greenCard) {
        result.workerCardName1 = i.name;
        result.workerCardExpiredDate1 = i.expire_date;
        result.workerCardNo1 = i.card_no;
      } else if (i.name === WorkCardDefault.registerCard) {
        result.workerCardName2 = i.name;
        result.workerCardExpiredDate2 = i.expire_date;
        result.workerCardNo2 = i.card_no;
        result.workerCardWorkType2 = i.worker_type_id;
      } else if (i.name === WorkCardDefault.blueCard) {
        result.workerCardName3 = i.name;
        result.workerCardExpiredDate3 = i.expire_date;
        result.workerCardNo3 = i.card_no;
      } else if (result.workerCardNo4) {
        // 如果第四张卡已经存在数据,将值赋值给第五张卡
        result.workerCardName5 = i.name;
        result.workerCardExpiredDate5 = i.expire_date;
        result.workerCardNo5 = i.card_no;
      } else {
        // 默认赋值给第四张卡
        result.workerCardName4 = i.name;
        result.workerCardExpiredDate4 = i.expire_date;
        result.workerCardNo4 = i.card_no;
      }
    });
  }
  if (Array.isArray(data.listName)) {
    let newList = '';
    data.listName.forEach((i, k) => {
      if (k < data.listName.length - 1) {
        newList += `${i}, `
      } else {
        newList += `${i}`
      }
    })
    const list = data.listName.map(i => ({ value: i, label: i }))
    result.listName = list
    result.newlistName = newList;
  }
  return result;
};

export const saveContractor = async data => {
  const {
    drivingLicenseExpire,
    cardNo,
    surname,
    otherName,
    sex,
    nameAlias,
    commercialCodeAlias,
    identityCard,
    birthday,
    placeOfBirth,
    nationality, // 国籍
    address,
    telephone,
    telephoneSpare,
    // 紧急联系人
    emergencyContactedName,
    emergencyContactedRelationship,
    emergencyContactedAddress,
    emergencyContactedTelephone,

    // partB
    contractNumber, // 主分包商编号
    contractPosition,
    contractSubcontractor,
    contractSubcontractorName,
    contractEmployer,
    contractFrom, // 合同开始时间
    contractTo, // 合同结束时间
    contractResident,
    contractApplicantDrive, // 是否申请车辆通行证
    contractVehicle, // 车牌号

    // partC
    checkedApproved,
    checkedClassification,
    checkedSpecified,
    checkedExpiry, // 申请过期时间
    checkedReasons, // 申请拒绝原因
    // 头像
    headPhoto,
    annexes,

    workerCardExpiredDate1,
    workerCardNo1,
    workerCardName1,

    workerCardExpiredDate2,
    workerCardNo2,
    workerCardName2,
    workerCardWorkType2,

    workerCardExpiredDate3,
    workerCardNo3,
    workerCardName3,

    workerCardExpiredDate4,
    workerCardNo4,
    workerCardName4,

    workerCardExpiredDate5,
    workerCardNo5,
    workerCardName5,
    isBlack,
    groupName,
    isInfected,
    email,
    id_base64,
    green_base64,
    drive_base64,
    regist_base64,
    vacc_base64,
    exemption_base64,
    drive_certificate_base64,
    safety_certificate_base64,
    inspect_certificate_base64,
    ...other
  } = data;

  const vaccinationDate1 = data.vaccination_date1;
  const vaccinationDate2 = data.vaccination_date2;
  const vaccinationDate3 = data.vaccination_date3;
  const vaccinationDate4 = data.vaccination_date4;
  const vaccinationDate5 = data.vaccination_date5;

  const inspectionDate = data.inspection_exemption_time;
  // vaccinationDate2,
  // vaccinationDate3,
  // vaccinationDate4,
  // vaccinationDate5,
  // 处理卡片数组
  const cardArr = [
    {
      name: workerCardName1,
      card_no: workerCardNo1,
      expire_date: workerCardExpiredDate1
        ? moment(workerCardExpiredDate1).format(datetimeFormat.date)
        : null,
    },
    {
      name: workerCardName2,
      card_no: workerCardNo2,
      expire_date: workerCardExpiredDate2
        ? moment(workerCardExpiredDate2).format(datetimeFormat.date)
        : null,
      worker_type_id: workerCardWorkType2,
    },
  ];
  if (workerCardNo3) {
    cardArr.push({
      name: workerCardName3,
      card_no: workerCardNo3,
      expire_date: workerCardExpiredDate3
        ? moment(workerCardExpiredDate3).format(datetimeFormat.date)
        : null,
    });
  }
  if (workerCardNo4) {
    cardArr.push({
      name: workerCardName4,
      card_no: workerCardNo4,
      expire_date: workerCardExpiredDate4
        ? moment(workerCardExpiredDate4).format(datetimeFormat.date)
        : null,
    });
  }
  if (workerCardNo5) {
    cardArr.push({
      name: workerCardName5,
      card_no: workerCardNo5,
      expire_date: workerCardExpiredDate5
        ? moment(workerCardExpiredDate5).format(datetimeFormat.date)
        : null,
    });
  }

  // 处理图片
  let headPhotoBase64 = null;
  if (Array.isArray(headPhoto) && headPhoto.length > 0) {
    headPhotoBase64 = headPhoto[0].thumbUrl;
  }
  let annexesBase64 = [];
  if (Array.isArray(annexes)) {
    annexesBase64 = annexes.map(item => item.thumbUrl);
  }
  let listName = null;
  if (Array.isArray(groupName)) {
    listName = groupName.map(i => `${i.value}`)
  }
  const param = {
    ...other,
    driving_license_expire: drivingLicenseExpire
      ? moment(drivingLicenseExpire).format(datetimeFormat.date)
      : null,

    card_no: cardNo,
    other_names: otherName,

    surname,
    birthday: birthday ? moment(birthday).format(datetimeFormat.date) : null,
    nationality,
    address,
    telephone,
    telephone_spare: telephoneSpare,
    name_alias: nameAlias,

    commercial_code_alias: commercialCodeAlias,
    identity_card: identityCard,
    sex,
    place_of_birth: placeOfBirth,

    emergency_contacted_name: emergencyContactedName,
    emergency_contacted_relationship: emergencyContactedRelationship,
    emergency_contacted_address: emergencyContactedAddress,
    emergency_contacted_telephone: emergencyContactedTelephone,
    imported_labour_identity: '1',
    has_resident: contractResident,
    need_drivng: contractApplicantDrive,
    email,

    contract_number: contractNumber,
    contract_position: contractPosition,
    contract_subcontractor: contractSubcontractorName ? `${contractSubcontractorName.name}` : null,
    contract_subcontractor_id: contractSubcontractor,
    contract_employer: contractEmployer,
    contract_from: contractFrom ? moment(contractFrom).format(datetimeFormat.date) : null,
    contract_to: contractTo ? moment(contractTo).format(datetimeFormat.date) : null,
    contract_vehicle: contractVehicle,

    checked_approved: checkedApproved,
    checked_classification: checkedClassification,
    // 字段重命名.后端 zone_list 字段是一个数组
    zone_list: checkedSpecified,
    checked_expiry: checkedExpiry ? moment(checkedExpiry).format(datetimeFormat.date) : null,
    checked_reasons: checkedReasons,

    head_photo: headPhotoBase64,
    annexes: annexesBase64,
    id_base64: setNewDataList(id_base64),
    green_base64: setNewDataList(green_base64),
    drive_base64: setNewDataList(drive_base64),
    regist_base64: setNewDataList(regist_base64),
    vacc_base64: setNewDataList(vacc_base64),
    exemption_base64: setNewDataList(exemption_base64),
    drive_certificate_base64: setNewDataList(drive_certificate_base64),
    safety_certificate_base64: setNewDataList(safety_certificate_base64),
    inspect_certificate_base64: setNewDataList(inspect_certificate_base64),

    card_list: cardArr,
    vaccination_date1: vaccinationDate1
      ? moment(vaccinationDate1).format(datetimeFormat.date)
      : null,
    vaccination_date2: vaccinationDate2
      ? moment(vaccinationDate2).format(datetimeFormat.date)
      : null,
    vaccination_date3: vaccinationDate3
      ? moment(vaccinationDate3).format(datetimeFormat.date)
      : null,
    vaccination_date4: vaccinationDate4
      ? moment(vaccinationDate4).format(datetimeFormat.date)
      : null,
    vaccination_date5: vaccinationDate5
      ? moment(vaccinationDate5).format(datetimeFormat.date)
      : null,
    isBlack: isBlack ? 2 : 1,
    listName,
    inspection_exemption_time: inspectionDate
      ? moment(inspectionDate).format(datetimeFormat.date)
      : null,
    isInfected: isInfected ? 2 : 1,
  };
  console.log('保存的數據', param, data)
  const response = await requestPostByToken({
    url: url.contractorUrl.save,
    body: param,
  });
  return response;
};

export const removeById = id =>
  requestDeleteByToken({
    url: url.contractorUrl.removeById.replace('{id}', id),
  });

export const updateById = ({ id, body }) => {
  const {
    drivingLicenseExpire,
    cardGroupId,
    fileGroupId,
    // cardNo,
    surname,
    otherName,
    sex,
    nameAlias,
    commercialCodeAlias,
    identityCard,
    birthday,
    placeOfBirth,
    nationality, // 国籍
    address,
    telephone,
    telephoneSpare,
    // 紧急联系人
    emergencyContactedName,
    emergencyContactedRelationship,
    emergencyContactedAddress,
    emergencyContactedTelephone,

    // partB
    contractNumber, // 主分包商编号
    contractPosition,
    contractSubcontractor,
    contractSubcontractorName,
    contractEmployer,
    contractFrom, // 合同开始时间
    contractTo, // 合同结束时间
    contractResident,
    contractApplicantDrive, // 是否申请车辆通行证
    contractVehicle, // 车牌号

    // partC
    checkedApproved,
    checkedClassification,
    checkedSpecified,
    checkedExpiry, // 申请过期时间
    checkedReasons, // 申请拒绝原因
    // 头像
    headPhoto,
    annexes,
    cardBack,
    cardFront,

    workerCardExpiredDate1,
    workerCardNo1,
    workerCardName1,

    workerCardExpiredDate2,
    workerCardNo2,
    workerCardName2,
    workerCardWorkType2,

    workerCardExpiredDate3,
    workerCardNo3,
    workerCardName3,

    workerCardExpiredDate4,
    workerCardNo4,
    workerCardName4,

    workerCardExpiredDate5,
    workerCardNo5,
    workerCardName5,

    isBlack,
    groupName,
    newcardNo,

    isInfected,
    email,
    id_base64,
    green_base64,
    drive_base64,
    regist_base64,
    vacc_base64,
    exemption_base64,
    drive_certificate_base64,
    safety_certificate_base64,
    inspect_certificate_base64,
  } = body;
  const vaccinationDate1 = body.vaccination_date1;
  const vaccinationDate2 = body.vaccination_date2;
  const vaccinationDate3 = body.vaccination_date3;
  const vaccinationDate4 = body.vaccination_date4;
  const vaccinationDate5 = body.vaccination_date5;

  const inspectionDate = body.inspection_exemption_time;
  // 处理卡片数组
  const cardArr = [
    {
      name: workerCardName1,
      card_no: workerCardNo1,
      expire_date: workerCardExpiredDate1
        ? moment(workerCardExpiredDate1).format(datetimeFormat.date)
        : null,
    },
    {
      name: workerCardName2,
      card_no: workerCardNo2,
      expire_date: workerCardExpiredDate2
        ? moment(workerCardExpiredDate2).format(datetimeFormat.date)
        : null,
      worker_type_id: workerCardWorkType2,
    },
  ];
  if (workerCardNo3) {
    cardArr.push({
      name: workerCardName3,
      card_no: workerCardNo3,
      expire_date: workerCardExpiredDate3
        ? moment(workerCardExpiredDate3).format(datetimeFormat.date)
        : null,
    });
  }
  if (workerCardNo4) {
    cardArr.push({
      name: workerCardName4,
      card_no: workerCardNo4,
      expire_date: workerCardExpiredDate4
        ? moment(workerCardExpiredDate4).format(datetimeFormat.date)
        : null,
    });
  }
  if (workerCardNo5) {
    cardArr.push({
      name: workerCardName5,
      card_no: workerCardNo5,
      expire_date: workerCardExpiredDate5
        ? moment(workerCardExpiredDate5).format(datetimeFormat.date)
        : null,
    });
  }
  // 处理图片
  let headPhotoBase64 = null;
  if (Array.isArray(headPhoto) && headPhoto.length > 0) {
    headPhotoBase64 = headPhoto[0].url || headPhoto[0].thumbUrl;
  }
  let annexesBase64 = [];
  if (Array.isArray(annexes)) {
    annexesBase64 = annexes.map(item => item.url || item.thumbUrl);
  }
  let listName = null;
  if (Array.isArray(groupName)) {
    listName = groupName.map(i => `${i.value}`)
  }
  const param = {
    driving_license_expire: drivingLicenseExpire
      ? moment(drivingLicenseExpire).format(datetimeFormat.date)
      : null,
    card_back: cardBack,
    card_front: cardFront,
    other_names: otherName,

    surname,
    birthday: birthday ? moment(birthday).format(datetimeFormat.date) : null,
    nationality,
    address,
    telephone,
    telephone_spare: telephoneSpare,
    name_alias: nameAlias,

    commercial_code_alias: commercialCodeAlias,
    identity_card: identityCard,
    sex,
    place_of_birth: placeOfBirth,

    emergency_contacted_name: emergencyContactedName,
    emergency_contacted_relationship: emergencyContactedRelationship,
    emergency_contacted_address: emergencyContactedAddress,
    emergency_contacted_telephone: emergencyContactedTelephone,
    imported_labour_identity: '1',
    has_resident: contractResident,
    need_drivng: contractApplicantDrive,
    email,

    contract_number: contractNumber,
    contract_position: contractPosition,
    contract_subcontractor: contractSubcontractorName ? `${contractSubcontractorName.name}` : null,
    contract_subcontractor_id: contractSubcontractor,
    contract_employer: contractEmployer,
    contract_from: contractFrom ? moment(contractFrom).format(datetimeFormat.date) : null,
    contract_to: contractTo ? moment(contractTo).format(datetimeFormat.date) : null,
    contract_vehicle: contractVehicle,

    checked_approved: checkedApproved,
    checked_classification: checkedClassification,
    zone_list: checkedSpecified,
    checked_expiry: checkedExpiry ? moment(checkedExpiry).format(datetimeFormat.date) : null,
    checked_reasons: checkedReasons,

    head_photo: headPhotoBase64,
    annexes: annexesBase64,
    card_list: cardArr,
    file_group_id: fileGroupId,
    card_group_id: cardGroupId,
    card_no: newcardNo,
    vaccination_date1: vaccinationDate1
      ? moment(vaccinationDate1).format(datetimeFormat.date)
      : null,
    vaccination_date2: vaccinationDate2
      ? moment(vaccinationDate2).format(datetimeFormat.date)
      : null,
    vaccination_date3: vaccinationDate3
      ? moment(vaccinationDate3).format(datetimeFormat.date)
      : null,
    vaccination_date4: vaccinationDate4
      ? moment(vaccinationDate4).format(datetimeFormat.date)
      : null,
    vaccination_date5: vaccinationDate5
      ? moment(vaccinationDate5).format(datetimeFormat.date)
      : null,
    isBlack: isBlack ? 2 : 1,
    listName,
    inspection_exemption_time: inspectionDate
      ? moment(inspectionDate).format(datetimeFormat.date)
      : null,
    isInfected: isInfected ? 2 : 1,
    id_base64: setDataList(id_base64),
    green_base64: setDataList(green_base64),
    drive_base64: setDataList(drive_base64),
    regist_base64: setDataList(regist_base64),
    vacc_base64: setDataList(vacc_base64),
    exemption_base64: setDataList(exemption_base64),
    drive_certificate_base64: setDataList(drive_certificate_base64),
    safety_certificate_base64: setDataList(safety_certificate_base64),
    inspect_certificate_base64: setDataList(inspect_certificate_base64),

  };
  return requestPutByToken({
    url: url.contractorUrl.modifyById.replace('{id}', id),
    body: param,
  });
};
